﻿using System;
using System.IO;
using System.Web.UI;

using ScottCateAjax2008.Utilities;

namespace ScottCateAjax2008.Common
{
    public partial class WebSiteMaster : MasterPage
    {
        protected void Page_Load( object sender, EventArgs e )
        {
            ASPXFileHyperlink.NavigateUrl = "~/Utilities/ShowServerCode.aspx?res=" + Utils.ScriptName;

            //Show C# Source Link?
            string csFile = Utils.ScriptName + ".cs";
            if( File.Exists( Server.MapPath( csFile ) ) )
            {
                CodeFileHyperLink.NavigateUrl = "~/Utilities/ShowServerCode.aspx?res=" + csFile;
            }
            else
            {
                CodeFileHyperLink.Visible = false;
            }

            //Show JS Source Link?
            string jsFile = Utils.ScriptName + ".js";
            if( File.Exists( Server.MapPath( jsFile ) ) )
            {
                JavaScriptCodeHyperLink.NavigateUrl = "~/Utilities/ShowJavaScript.aspx?url=~" + jsFile;
            }
            else
            {
                JavaScriptCodeHyperLink.Visible = false;
            }

            //Show Atlas Source Link?
            string atlasFile = Utils.ScriptName + ".atlas";
            if( File.Exists( Server.MapPath( atlasFile ) ) )
            {
                atlasLiteral.Text = "&nbsp;/&nbsp;";
                atlasFileHyperlink.NavigateUrl = "~/Utilities/ShowServerCode.aspx?res=" + atlasFile;
            }
            else
            {
                atlasLiteral.Text = string.Empty;
                atlasFileHyperlink.Visible = false;
            }
        }
    }
}